package org.easiermock.invocationhandlers;

import java.lang.reflect.Proxy;

import static org.junit.Assert.assertEquals;
import org.junit.Test;

public class DoNothingInvocationHandlerTest {
	@Test
	public void testReturnValues() {
		// Create a dynamic proxy to call to run the test
		TestInterface testObject = 
			(TestInterface) Proxy.newProxyInstance(
				Thread.currentThread().getContextClassLoader(), 
				new Class[] { TestInterface.class }, 
				DoNothingInvocationHandler.INSTANCE);
		
		testObject.voidMethod();
		assertEquals((byte)0, testObject.byteMethod());
		assertEquals((short)0, testObject.shortMethod());
		assertEquals(0, testObject.intMethod());
		assertEquals(0L, testObject.longMethod());
		assertEquals(0.0f, testObject.floatMethod(), 0.0f);
		assertEquals(0.0, testObject.doubleMethod(), 0.0);
		assertEquals((char)0, testObject.charMethod());
		assertEquals(false, testObject.booleanMethod());
		assertEquals(null, testObject.objectMethod());
	}
	
	public static interface TestInterface {
		void voidMethod();
		byte byteMethod();
		short shortMethod();
		int intMethod();
		long longMethod();
		float floatMethod();
		double doubleMethod();
		char charMethod();
		boolean booleanMethod();
		Object objectMethod();
	}
}
